#ifndef __kraw__Event_h__
#define __kraw__Event_h__
/**
	@file Event.h
*/

#include <string>
#include <vector>
#include <map>

namespace kraw
{
	class ObjectNode;
	class ObjectEvent
	{
	public:
		ObjectEvent(const std::string& _type) :
		type(_type)
		{}

		std::string type;
		ObjectNode* target;
	};

	class EventListener
	{
	public:
		virtual void onEvent(ObjectEvent* event) = 0;
	};

	class EventDispatcher
	{
	public:
		EventDispatcher();
		virtual ~EventDispatcher();

		void addEventListener(const std::string& type, EventListener* listener);
		bool hasEventListener(const std::string& type);
		void removeEventListener(const std::string& type, EventListener* listener);

		void dispatchEvent(ObjectEvent* event);

		std::map<std::string, std::vector<EventListener*> > listeners;
	};
}

#endif
